/*
 * Copyright © 2017 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

@import '~styles/variables.scss';
@import '../DataPrep/DataPrepBrowser/DataprepBrowserVariables.scss';

$connections-panel-bg-color: $grey-07;
$connections-panel-border-color: $grey-05;
$connections-menu-active-color: var(--brand-primary-color);
$connections-menu-item-color: $grey-01;
$info-font-color: $grey-03;
$expanded-menu-icon-width: 40px;

.dataprep-connections-container {
  height: calc(100vh - (#{$height-of-footer} + #{$height-of-header}));
  border-right: 1px solid $connections-panel-border-color;

  .connections-panel,
  .connections-content {
    float: left;
    height: 100%;
  }

  .connections-panel {
    display: grid;
    grid-template-rows: 50px 1fr 60px;
    width: 250px;
    background-color: $connections-panel-bg-color;
    border-right: 1px solid $connections-panel-border-color;

    .panel-title {
      margin: 15px 0;
      padding-left: 15px;
      cursor: pointer;
      text-overflow: ellipsis;

      h5 {
        font-size: 14px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow-x: hidden;

        .panel-toggle-icon {
          padding-right: 5px;
          vertical-align: top;
        }
      }
    }

    .connections-menu {
      border-bottom: 1px solid $connections-panel-border-color;
      overflow-y: auto;

      .menu-item {
        padding: 0;
        cursor: pointer;

        .fa { margin-right: 10px; }

        &:not(:last-child) {
          border-bottom: 1px solid $connections-panel-border-color;
        }

        &.expandable-menu {
          padding: 10px 0;
        }
        a {
          color: $connections-menu-item-color;
          display: inline-block;
          width: 100%;
          padding: 10px 15px 10px 35px;

          &:active,
          &:focus {
            text-decoration: none;
            outline: 0;
          }
          &:hover {
            text-decoration: none;
            font-weight: 600;
          }

          &.active {
            font-weight: 600;
            color: $connections-menu-active-color;
            background: white;

            ~ .expanded-menu-popover-icon {
              background: white;
            }
          }
        }

        .menu-item-expanded-list {
          padding: 10px 0 10px 54px;
          width: calc(100% - #{$expanded-menu-icon-width});
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .expanded-menu-popover-icon {
          width: $expanded-menu-icon-width;
          height: 39px;
          display: inline-block;

          > .fa {
            margin-right: 0;
          }
        }

        &.expandable {
          .expandable-title {
            padding-bottom: 5px;
            user-select: none;
          }
        }
      }
    }
  }

  .connections-content {
    width: calc(100% - 250px);

    .sub-panel {
      padding: 4px 10px;
      display: flex;
      align-items: center;
      .path-container,
      .info-container {
        width: 50%;
      }
      .path-container {
        padding-right: 10px;
        .file-path-container {
          height: 100%;
          .paths {
            display: inline-flex;
            align-items: center;
            height: inherit;
            width: 100%;
            overflow: hidden;

            a.active-directory {
              overflow: hidden;
              text-overflow: ellipsis;
            }
          }
          .collapsed-paths {
            display: flex;
            height: 100%;
            align-items: center;
          }
        }
      }
      .info-container {
        display: flex;
        justify-content: center;
        align-items: center;
        padding-left: 10px;
        justify-content: flex-end;
        .info {
          flex: 0.7;
          font-size: 12px;
          color: $info-font-color;
          text-align: right;
          padding-right: 5px;
          overflow: hidden;
          word-break: inherit;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .search-container {
          flex: 0.3;
        }
      }
    }
    &.expanded { width: 100%; }
  }
}
